//
//  YyxLocationManger.h
//  YyxLocationManger
//
//  Created by imac on 15/6/29.
//  Copyright (c) 2015年 imac. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#define  YyxLastLongitude @"MMLastLongitude"
#define  YyxLastLatitude  @"MMLastLatitude"
#define  YyxLastCity      @"MMLastCity"
#define  YyxLastAddress   @"MMLastAddress"

#define  YyxIOS8      ([[[[UIDevice currentDevice] systemVersion] substringToIndex:1] intValue]>=8)

#import <CoreLocation/CoreLocation.h>


typedef void (^LocationBlock)(CLLocationCoordinate2D locationCorrrdinate);
typedef void (^LocationErrorBlock) (NSError *error);
typedef void(^NSStringBlock)(NSString *cityString);
typedef void(^NSStringBlock)(NSString *addressString);



@interface YyxLocationManger : NSObject


@property (nonatomic) CLLocationCoordinate2D lastCoordinate;
@property(nonatomic,strong)NSString *lastCity;
@property (nonatomic,strong) NSString *lastAddress;

@property(nonatomic,assign)double latitude;
@property(nonatomic,assign)double longitude;

+ (YyxLocationManger *)shareLocation;

-(NSString *)getLastCity;

/**
 *  获取坐标
 *
 *  @param locaiontBlock locaiontBlock description
 */
- (void) getLocationCoordinate:(LocationBlock) locaiontBlock error:(LocationErrorBlock) errorBlock;

/**
 *  获取坐标和地址
 *
 *  @param locaiontBlock locaiontBlock description
 *  @param addressBlock  addressBlock description
 */
- (void) getLocationCoordinate:(LocationBlock) locaiontBlock  withAddress:(NSStringBlock) addressBlock error:(LocationErrorBlock) errorBlock;

/**
 *  获取地址
 *
 *  @param addressBlock addressBlock description
 */
- (void) getAddress:(NSStringBlock)addressBlock error:(LocationErrorBlock) errorBlock;

/**
 *  获取城市和定位失败
 *
 *  @param cityBlock  cityBlock description
 *  @param errorBlock errorBlock description
 */
- (void) getCity:(NSStringBlock)cityBlock error:(LocationErrorBlock) errorBlock;


-(void)startLocation;
@end
